import { getCamignList, getCampaignDetail, getWePageList, newCampaign, setActivityPage, setPostPageData, getPosterList, getCampaignReport1,
    getCampaignReport2, getCampaignReport3, issueCampaign, issueCampaign2, issueCampaign3, savePostPageData, getWXvalidAccountList, setWxMpInfo, delCampaignItem, setActivityTime } from '@/service/getData'
import * as type from '@/store/mutation-types'
const state = {
    campaignList: {
        list: [],
        page: {}
    },
    detailData: [],
    reportData1: [],
    reportData2: [],
    reportData3: []
}
const actions = {
    //获取营销活动列表
    async getCampignData ({commit, state}, payload) {
        let res = await getCamignList(payload)
        commit(type.GET_CAMPAIGNLIST, res.data.data)
        state.campaignList = res.data.data
        return res
    },
    async newCampaignData({ commit, state }, payload) {
        let res = await newCampaign(payload)
        return res
    },
    async getCampaignDetail({ commit, state }, payload) {
        let res = await getCampaignDetail(payload)
        commit(type.GET_CAMPAIGNDETAIL, res.data.data)
        state.detailData = res.data.data
        return res
    },
    async getActivityPageData({ commit, state }, payload) {
        let res = await getWePageList(payload)
        return res
    },
    async setActivityPageData({ commit, state }, payload) {
        let res = await setActivityPage(payload)
        return res
    },
    async getPosterPageData({ commit, state }, payload) {
        let res = await getPosterList(payload)
        return res
    },
    async setPostData({ commit, state }, payload) {
        let res = await setPostPageData(payload)
        return res
    },
    async savePostData({ commit, state }, payload) {
        let res = await savePostPageData(payload)
        return res
    },
    async getCampaignReport1 ({commit, state}, payload) {
        let res = await getCampaignReport1(payload)
        commit('SET_CAMPAIGN_REPORT1', res.data.data)
        return res
    },
    async getCampaignReport2 ({commit, state}, payload) {
        let res = await getCampaignReport2(payload)
        commit('SET_CAMPAIGN_REPORT2', res.data.data)
        return res
    },
    async getCampaignReport3 ({commit, state}, payload) {
        let res = await getCampaignReport3(payload)
        commit('SET_CAMPAIGN_REPORT3', res.data.data)
        return res
    },
    async issueCampaign ({commit, state}, payload) {
        let res = await issueCampaign(payload)
        return res
    },
    async issueCampaign2({ commit, state }, payload) {
        let res = await issueCampaign2(payload)
        return res
    },
    async issueCampaign3({ commit, state }, payload) {
        let res = await issueCampaign3(payload)
        return res
    },
    async getWXvalidList({ commit, state }, payload) {
        let res = await getWXvalidAccountList(payload)
        return res
    },
    async setWxMpInformation({ commit, state }, payload) {
        let res = await setWxMpInfo(payload)
        return res
    },
    async delCampaignData({ commit, state }, payload) {
        let res = await delCampaignItem(payload)
        return res
    },
    async updateActivityTime({ commit, state }, payload) {
        let res = await setActivityTime(payload)
        return res
    }
}
const mutations = {
    [type.GET_CAMPAIGNLIST](state, payload) {
        // state.campaignList = payload
    },
    [type.GET_CAMPAIGNDETAIL](state, payload) {
        // state.campaignList = payload
    },
    ['SET_CAMPAIGN_REPORT1'] (state, payload) {
        state.reportData1 = payload
    },
    ['SET_CAMPAIGN_REPORT2'] (state, payload) {
        state.reportData2 = payload
    },
    ['SET_CAMPAIGN_REPORT3'] (state, payload) {
        state.reportData3 = payload
    }
}
export default {
    state,
    actions,
    mutations
}
